package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MOrderform;
import com.ruoyi.system.service.IMOrderformService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 销售订单管理Controller
 * 
 * @author lzt
 * @date 2024-05-09
 */
@RestController
@RequestMapping("/system/orderform")
public class MOrderformController extends BaseController
{
    @Autowired
    private IMOrderformService mOrderformService;

    /**
     * 查询销售订单管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:orderform:list')")
    @GetMapping("/list")
    public TableDataInfo list(MOrderform mOrderform)
    {
        startPage();
        List<MOrderform> list = mOrderformService.selectMOrderformList(mOrderform);
        return getDataTable(list);
    }

    /**
     * 导出销售订单管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:orderform:export')")
    @Log(title = "销售订单管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MOrderform mOrderform)
    {
        List<MOrderform> list = mOrderformService.selectMOrderformList(mOrderform);
        ExcelUtil<MOrderform> util = new ExcelUtil<MOrderform>(MOrderform.class);
        util.exportExcel(response, list, "销售订单管理数据");
    }

    /**
     * 获取销售订单管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:orderform:query')")
    @GetMapping(value = "/{number}")
    public AjaxResult getInfo(@PathVariable("number") Long number)
    {
        return success(mOrderformService.selectMOrderformByNumber(number));
    }

    /**
     * 新增销售订单管理
     */
    @PreAuthorize("@ss.hasPermi('system:orderform:add')")
    @Log(title = "销售订单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MOrderform mOrderform)
    {
        return toAjax(mOrderformService.insertMOrderform(mOrderform));
    }

    /**
     * 修改销售订单管理
     */
    @PreAuthorize("@ss.hasPermi('system:orderform:edit')")
    @Log(title = "销售订单管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MOrderform mOrderform)
    {
        return toAjax(mOrderformService.updateMOrderform(mOrderform));
    }

    /**
     * 删除销售订单管理
     */
    @PreAuthorize("@ss.hasPermi('system:orderform:remove')")
    @Log(title = "销售订单管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{numbers}")
    public AjaxResult remove(@PathVariable Long[] numbers)
    {
        return toAjax(mOrderformService.deleteMOrderformByNumbers(numbers));
    }
}
